<?php
namespace app\admin\model;


use think\facade\Cache;
use think\Model;

class Category extends Model
{
    public function goodsCate($id)
    {

        $list= Category::table('ecm_category')->where('parentid',$id)->order('sort')->select()->toArray();
        $all = Cache::get('category');
        if (!$all) {
            $all = Category::table('ecm_category')->select()->toArray();
            Cache::set('category', $all, 60);
        }
        foreach ($list as &$v) {
            foreach ($all as $vv) {
                if ($v['id'] == $vv['parentid']) {
                    $v['next'] = '1';
                }
            }
        }


        return $list;

    }
}